package com.tubi.ArrayList;

import com.tubi.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayList键盘学生集合 {

    public static void main(String[] args) {
        //创建学生集合
        ArrayList<Student> list = new ArrayList();
        for (int i = 0; i < 3; i++) {
            Student student = getStudent();
            list.add(student);
        }

        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            System.out.println(student.getName()+"-----"+student.getAge());
        }
    }

    private static Student getStudent() {
        //键盘录入
        Scanner sc = new Scanner(System.in);
        System.out.println("请录入学生人信息");
        String name = sc.next();
        int i1 = sc.nextInt();
        Student s = new Student(name, i1);
        return s;
    }
}
